#!/bin/bash
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock --systohc

echo -e "en_US.UTF-8 UTF-8\nzh_CN.UTF-8 UTF-8\nzh_CN.GBK GBK" >> /etc/locale.gen
locale-gen 
echo "LANG=zh_CN.UTF-8" > /etc/locale.conf

echo "archlinux" > /etc/hostname
echo -e "127.0.0.1   localhost\n::1              localhost\n127.0.1.1 archlinux.localdomain archlinux" > /etc/hosts
passwd

echo -e "which type is your cpu?\n1.intel 2.amd"
read cpu
if [ $cpu -eq 2 ];then
pacman -S  amd-ucode mesa xf86-video-ati --noconfirm
else
pacman -S intel-ucode xf86-video-intel mesa --noconfirm
fi


pacman -S os-prober grub efibootmgr --noconfirm

echo -e "which type is your boot?\n1.uefi or virtualbox 2.mbr "
read uefi
if [ $uefi -eq 1 ];then
grub-install --target=x86_64-efi  --efi-directory=/boot/efi --bootloader-id=Archlinux  --recheck
else
lsblk
echo "input system disk(like sda/sdb)"
read mbr
grub-install --target=i386-pc /dev/$mbr
fi
grub-mkconfig -o /boot/grub/grub.cfg
pacman -S iw wpa_supplicant dialog  netctl --noconfirm
systemctl enable dhcpcd

echo "input your account name:"
read user
useradd -m -g users -s /bin/bash $user
passwd $user
echo -e "$user ALL=(ALL:ALL)  ALL" >> /etc/sudoers


pacman -S ttf-dejavu wqy-microhei wqy-zenhei networkmanager netctl unzip unrar fastfetch openssh --noconfirm
systemctl enable NetworkManager sddm dhcpcd sshd


echo "please run xdg-user-dirs-update --force after login as local user" |tee /home/$user/notice.txt
cp ./custom.sh ./custom_wayland.sh ./custom_server.sh ./99-gpu.conf ./99-gpu-nvidia_prefer.conf ./nvidia_driver.sh ./switch.sh /home/$user/
exit
